<?php
include('./mysql.php');

$uuid = $_POST['uuid'];
$username = $_POST['username'];
$student_number = $_POST['student_number'];
$major = $_POST['major'];
$curriculum = $_POST['curriculum'];
$teacher = $_POST['teacher'];
$score = $_POST['score'];
$time = $_POST['time'];

// // 查询老师是否存在, 不存在就创建该老师
// $has_teacher = $conn->query('SELECT * FROM teacher WHERE `name` = \''. $teacher . '\'')->fetch_assoc();
// print_r($has_teacher);
// if (!$has_teacher) {
//     $major_id = $conn->query('SELECT * FROM major WHERE `name` = \'' . $major . '\'')->fetch_assoc()->id;
//     $conn->query('INSERT INTO `teacher` ( `major_id` `name` ) VALUES ( '.$major_id.', '.$teacher.' )');
// }

$sql = 'INSERT INTO `score` (`uuid`, `username`, `student_number`, `major`, `curriculum`, `teacher`, `score`, `time`) VALUES ( ?, ?, ?, ?, ?, ?, ?, ? )';
$result = $conn->prepare($sql);
$result->bind_param('ssssssss', $uuid, $username, $student_number, $major, $curriculum, $teacher, $score, $time);
$result->execute();

echo '提交成功';